<?php
namespace app\index\controller;
use think\Controller\Rest;
use app\index\model\Admin;
use think\Request;
	class Shop extends Rest
	{
		public function qw(){
			cookie("name","yong");
			echo \cookie("name");
		}
		public function sa(){
			$user=input("get.user");
			$pass=input("get.pass");
			 $ad=new Admin();
			// $ad->sname=$user;
			// $ad->spass=$pass;
			// $ad->smd=substr(md5($pass),3,8);
			$r=array("sname"=>$user,"spass"=>$pass);
			$a=$ad->save($r);
			if($a==true){
				echo 123;
			}
		}
		public function index(){
			
			$res=Request::instance();
			$data["post"]=$res->isPost();
			$data["po"]=$_SERVER;
			$head=$res->header("token");
			$data["head"]=$head;
			$data['info']="成功";
			return json($data);
		}
		public function create(){//get
		header('Access-Control-Allow-Headers:token');
		header("Access-Control-Allow-Origin:http://localhost:8080");
		header("Access-Control-Allow-Credentials:true");	
				switch($this->method){
					case 'post':
					    $user=input("post.user");
						$pass=input("post.pass");
						$a=new Admin();
						$d=$a->zc($user,$pass);
						return json($d);
					//    $res=Request::instance();
					//	$data["post"]=$res->isPost();
					//	$data["po"]=$_SERVER;
						// $head=$res->header("token");
						// $data["head"]=$head;
							
						break;
					case 'get':
					$user=input("get.user");
					$pass=input("get.pass");
					$a=new Admin();
					$d=$a->zc($user,$pass);
					return json($d);
				}
		}
		public function save(){//post
		
			echo "save";//shop
		}
		public function read($id){//get
			echo "read";//shop/:id
		}
		public function edit($id){//get
			echo "edit";//shop/:id/edit
		}
		public function update(){//put
			echo "update";//shop/:id
		}
		public function delete(){//delete
			echo "create";//shop/:id
		}
	}